<?php
Route::group(['prefix' => config('constant.name_admin'), 'middleware' => ['auth:admin', 'checkrbac','addOperateLog']], function() {
    /* 微信公众平台 */
    Route::get('weChat/setGzhMenu', 'Admin\WeChatController@setGzhMenu'); //微信公众号菜单栏设置
    /* 微信公众平台 */
    //用户操作日志
    Route::group(['prefix' => 'manager'], function() {
        Route::any('oprateLog', 'Admin\ManagerController@oprateLog'); //列表
    });
    //定价
    Route::group(['prefix' => 'standard'], function() {
        Route::post('syncDataHb', 'Admin\StandardController@syncDataHb'); //同步汇邦标准
    });
    //定价
    Route::group(['prefix' => 'money'], function() {
        Route::get('index', 'Admin\MoneyController@Index'); //列表
        Route::post('edit', 'Admin\MoneyController@edit'); //编辑
    });
    //第三方系统对接
    Route::group(['prefix' => 'third'], function() {
        Route::any('index', 'Admin\ThirdController@Index');
        Route::any('add', 'Admin\ThirdController@edit');
        Route::any('edit', 'Admin\ThirdController@edit');
        Route::any('del', 'Admin\ThirdController@del');
        Route::any('map', 'Admin\ThirdController@map'); //数据相关关系映射
        Route::any('column', 'Admin\ThirdController@column'); //字段关系映射
        Route::any('uploadRes', 'Admin\ThirdController@uploadRes');
        Route::any('testItem', 'Admin\ThirdController@testItem');
        //第三方数据
        Route::group(['prefix' => 'data'], function() {
            Route::match(['get','post'],'index', 'Admin\ThirdController@data');  //待检数据
            Route::match(['get','post'],'all', 'Admin\ThirdController@dataAll');  //全部数据
            Route::post('upload', 'Admin\ThirdController@upload');  //上传
            Route::post('del', 'Admin\ThirdController@dataDel');  //删除
            Route::post('setClass', 'Admin\ThirdController@setDataClass');  //设置分类
            Route::any('add2Contract', 'Admin\ThirdController@dataAdd2Contract');  //受理新建或导入批次
        });
    });
    //共享文件
    Route::group(['prefix' => 'shareDir'], function() {
        Route::any('index', 'Admin\ShareDirController@Index');
        Route::any('add', 'Admin\ShareDirController@add');
        Route::post('edit', 'Admin\ShareDirController@edit');
        Route::any('del', 'Admin\ShareDirController@del');
        Route::any('sync', 'Admin\ShareDirController@sync');
        Route::any('preview', 'Admin\ShareDirController@preview'); 
    });
    //结果录入
    Route::group(['prefix' => 'itemData'], function() {
        Route::any('station', 'Admin\ItemDataController@station'); //检测设备列表
        Route::any('temHuiPreIndex', 'Admin\ItemDataController@temHuiPreIndex'); //温湿度气压计
    });

    //环境终端
    Route::group(['prefix' => 'temHuiPre'], function() {
        Route::get('log', 'Admin\TemHuiPreController@log'); //环境记录
        Route::get('exportLog', 'Admin\TemHuiPreController@exportLog'); //环境记录-导出
    });

    //检测设备
    Route::group(['prefix' => 'station'], function() {
        Route::get('index', 'Admin\StationController@index'); //展示
        Route::get('del', 'Admin\StationController@del'); //删除
        Route::any('add', 'Admin\StationController@add'); //添加
        Route::any('edit', 'Admin\StationController@edit'); //修改
        Route::post('import', 'Admin\StationController@import'); //导入
        Route::match(['get','post'],'upParam', 'Admin\StationController@upParam'); //设备软件数据 get-列表   post-添加、编辑
        //设备套装组合
        Route::group(['prefix' => 'group'], function() {
            Route::get('index', 'Admin\StationController@groupIndex'); //列表
            Route::post('edit', 'Admin\StationController@groupEdit'); //添加、编辑
            Route::post('del', 'Admin\StationController@groupDel'); //删除
        });
    });

    //录像机
    Route::group(['prefix' => 'vcr'], function() {
        Route::get('index', 'Admin\VcrController@index'); //展示
        Route::get('del', 'Admin\VcrController@del'); //删除
        Route::any('add', 'Admin\VcrController@add'); //添加
        Route::any('edit', 'Admin\VcrController@edit'); //修改
        Route::any('live', 'Admin\VcrController@live'); //预览
        Route::any('ysyAdd', 'Admin\VcrController@ysyAdd'); //同步到萤石云
    });

    //城市
    Route::group(['prefix' => 'city_code'], function() {
        Route::get('index', 'Admin\CityCodeController@index'); //展示
        Route::get('del', 'Admin\CityCodeController@del'); //删除
        Route::any('add', 'Admin\CityCodeController@add'); //添加
        Route::any('edit', 'Admin\CityCodeController@edit'); //修改
    });

    Route::group(['prefix' => 'statistics'], function() {
        Route::any('statisticsByClient', 'Admin\StatisticsController@statisticsByClient');       //合格数量 与 不合格数量 -- 按送检单位统计
        Route::any('statisticsByToolClass', 'Admin\StatisticsController@statisticsByToolClass'); ////合格数量 与 不合格数量 -- 按工器具分类统计
        Route::any('statisticsByTool', 'Admin\StatisticsController@statisticsByTool');           //按工器具统计
        Route::any('statisticsByManager', 'Admin\StatisticsController@byManager');           //按主捡人工作量统计
    });
    
    Route::group(['prefix' => 'contractGaiyao'], function() {
        Route::post('money', 'Admin\ContractGaiyaoController@money');  //获取单价
        Route::get('getThirdDj', 'Admin\ContractGaiyaoController@getThirdDj');  //获取第三方待检样品
        Route::any('edit/{id}', 'Admin\ContractGaiyaoController@edit');  //合同样品编辑
        Route::any('ajaxEditBarcode/{id}/{numcha}/{barcodes}', 'Admin\ContractGaiyaoController@ajaxEditBarcode'); //合同样品编辑条形码
        Route::any('changeStd', 'Admin\ContractGaiyaoController@changeStdAjax');  //切换工器具标准
        Route::any('addItem', 'Admin\ContractGaiyaoController@addItem'); //添加检测项目
        Route::any('changeClass', 'Admin\ContractGaiyaoController@changeClassAjax');   //修改分类
        //        批量结果录入
        Route::group(['prefix' => 'resLuru'], function() {
            Route::get('{contract_id}', 'Admin\ContractGaiyaoController@resLuru'); //列表
            // Route::post('itemData', 'Admin\ContractGaiyaoController@itemData'); //获取单项目信息(转移到只需登录，不需要验证权限组)
            Route::post('itemDataSub', 'Admin\ContractGaiyaoController@itemDataSub'); //提交单项目信息
        });
    });
    Route::group(['prefix' => 'contract'], function() {
        Route::get('exportBack/{id}', 'Admin\ContractController@exportBack'); //导出Excel
        Route::get('indexPay', 'Admin\ContractController@indexPay');          //支付操作列表
        Route::any('goPay/{id}', 'Admin\ContractController@goPay');           //支付操作
        Route::get('expire', 'Admin\ContractController@expire'); //到期预警
        Route::get('exportFF', 'Admin\ContractController@exportFF'); //下载分发单
        //上传平台
        Route::group(['prefix' => 'toThird'], function() {  //上传第三方系统
            Route::get('index', 'Admin\ContractController@toThirdIndex');  //列表
            Route::post('toThird', 'Admin\ContractController@toThird');  //上传
            Route::get('samples', 'Admin\ContractController@toThirdSamples');  //样品列表
        });
        //委托单来源
        Route::group(['prefix' => 'letter'], function() {
            Route::get('index', 'Admin\ContractLetterController@index');  //列表
        });
    });
    Route::group(['prefix' => 'sampleinfo'], function() {
        Route::any('notNotice/{barCode}', 'Admin\SampleInfoController@notNotice');                 //不再提醒预警到期
        Route::any('list', 'Admin\SampleInfoController@list');                                     //试验台账列表
        Route::get('imgdeal/{column}/{operate}/{bar_code}', 'Admin\SampleInfoController@imgdeal'); //不合格照片删除
        //备注模板
        Route::group(['prefix' => 'remark'], function() {
            Route::any('list', 'Admin\SampleInfoController@remarkList'); //列表
            Route::any('add', 'Admin\SampleInfoController@remarkAdd');   //添加
            Route::any('del', 'Admin\SampleInfoController@remarkDel');   //添加
        });
        Route::any('exportList/{isSearch}', 'Admin\SampleInfoController@exportList');      //试验完成导出
        Route::any('rejectLog/{iscontract}/{id}', 'Admin\SampleInfoController@rejectLog'); //驳回记录
        Route::any('printPass', 'Admin\SampleInfoController@printPass'); //自定义合格证打印
    });
    Route::group(['prefix' => 'sampleInfo'], function() {
        Route::get('gqjPlate', 'Admin\SampleInfoController@gqjPlate'); //获取铭牌信息
        Route::post('setRFID', 'Admin\SampleInfoController@setRFID'); //批次生产RFID
    });

    Route::group(['prefix' => 'setting'], function() {
        Route::any('testPlace/{func}/{val}', 'Admin\SettingController@testPlace'); //试验地点
        Route::any('warn_day_limit', 'Admin\SettingController@warnDaysLimit');     //预警时间设置
        Route::any('settingSys/{key}', 'Admin\SettingController@settingSys');      //系统设置
        // Route::get('backUp', 'Admin\SettingController@backUp');      //数据库备份(转移到只需登录，不需要验证权限组)
    });

    //工器具类型
    Route::group(['prefix' => 'tool'], function() {
        Route::get('exportToolItem', 'Admin\ToolController@exportToolItem'); //导出工器具类别及检测项目
        //工器具分类
        Route::group(['prefix' => 'class'], function() {
            Route::any('index', 'Admin\ToolClassController@index'); //列表
            Route::any('del', 'Admin\ToolClassController@del');     //删除
        });
    });

    Route::group(['prefix' => 'stdToolItemRel'], function() {
        Route::any('sort', 'Admin\StdToolItemRelController@sort'); //自动根据ID排序
        // Route::any('excel_pos_std_tool_item', 'Admin\StdToolItemRelController@excel_pos_std_tool_item'); //模板项目结果位置
    });

    Route::group(['prefix' => 'testdataKey'], function() {
        Route::get('hide', 'Admin\TestdataKeyController@hide');   //隐藏数据标题
        Route::any('relation', 'Admin\TestdataKeyController@relation'); //关联数据标题
    });
    Route::group(['prefix' => 'clientCode'], function() {
        Route::group(['prefix' => 'class'], function() {
            Route::any('index', 'Admin\ClientCodeController@classIndex');
            Route::any('del', 'Admin\ClientCodeController@classDel');
        });
    });

    //不合格照片、斗臂车照片
    Route::group(['prefix' => 'photo'], function() {
        Route::any('list', 'Admin\SampleInfoController@photoList'); //列表
	    Route::any('list/sub', 'Admin\SampleInfoController@photoListSub'); //提交
    });

    //微信jssdk
    Route::group(['prefix' => 'wxjssdk'], function() {
        Route::any('getSignPack', 'WeChatJSSDK@getSignPackage');
    });

    //报告模板
    Route::group(['prefix' => 'excelPos'], function() {
        Route::post('syncPos', 'Admin\ExcelPosController@syncPos'); //同步位置
        Route::post('add', 'Admin\ExcelPosController@add'); //同步位置
    });

    //生产厂家
    Route::group(['prefix' => 'factory'], function() {
        Route::any('index', 'Admin\FactoryController@index');
        Route::any('edit', 'Admin\FactoryController@edit');
        Route::any('del', 'Admin\FactoryController@del');
    });

    //通知
    Route::group(['prefix' => 'notice'], function() {
        //阿里大于短信
        Route::group(['prefix' => 'sms'], function() {
            Route::any('index', 'Admin\SmsController@index');
            Route::any('set', 'Admin\SmsController@set');
            Route::any('detail/{id}', 'Admin\SmsController@detail');
            Route::any('del', 'Admin\SmsController@del');
            Route::any('sendOne', 'Admin\SmsController@sendOne');   //重新发送短信
            //购买
            Route::group(['prefix' => 'buy'], function() {
                Route::any('index', 'Admin\SmsController@buyIndex');                //购买记录
                Route::any('add', 'Admin\SmsController@buyAdd');                    //添加
                Route::any('del/{id}', 'Admin\SmsController@buyDel');               //删除
                Route::any('audit/{id}/{stat}', 'Admin\SmsController@buyAudit');    //审核
            });
            //签名
            Route::group(['prefix' => 'sign'], function() {
                Route::any('index', 'Admin\SmsController@signIndex');           //签名记录
                Route::any('add', 'Admin\SmsController@signAdd');               //添加
                Route::any('edit/{id}', 'Admin\SmsController@signEdit');             //修改
                Route::any('del/{id}', 'Admin\SmsController@signDel');          //删除
                Route::any('def/{id}', 'Admin\SmsController@signDef');          //设置默认
                Route::any('detail/{id}', 'Admin\SmsController@signDetail');    //审核详情
            });
            //工器具
            Route::group(['prefix' => 'gqj'], function() {
                Route::any('set', 'Admin\SmsController@gqjSet'); //通知规则设置
            });
        });
    });
});

//无权限限制
Route::group(['prefix' => config('constant.name_admin'), 'middleware' => ['auth:admin','addOperateLog']], function() {
    Route::post('sampleInfo/addSamplePrint', 'Admin\SampleInfoController@addSamplePrint'); //增加打印次数
    Route::get('index/getWeather', 'Admin\IndexController@getWeather'); //获取天气信息
    Route::get('exportReport/origin', 'Admin\ExportReportController@origin'); //导出原始记录
    Route::group(['prefix' => 'index'], function() {
        Route::get('getWeather', 'Admin\IndexController@getWeather'); //获取天气信息
        Route::get('export', 'Admin\IndexController@export');  //导出合格证信息
    });
    Route::group(['prefix' => 'third/data'], function() {
        Route::get('paramGetDj', 'Admin\ThirdController@paramGetDj'); //根据条件获取待检信息
        Route::any('getOrgTree', 'Admin\ThirdController@getOrgTree');  //获取组织树
    });
    Route::get('excelPos/getTemplPos', 'Admin\ExcelPosController@getTemplPos'); //获取某个模板中的相关位置
    Route::get('itemData/inputHistory', 'Admin\ItemDataController@inputHistory'); //获取试验数据的历史记录
    Route::group(['prefix' => 'contractGaiyao'], function() {
        Route::post('money', 'Admin\ContractGaiyaoController@money');  //获取单价
        Route::post('resLuru/itemData', 'Admin\ContractGaiyaoController@itemData'); //批量结果录入--获取单项目信息
    });
    Route::get('setting/backUp', 'Admin\SettingController@backUp');      //数据库备份
    //LED智慧实验室中控室
    Route::group(['prefix' => 'zks'], function() {
        Route::any('index', 'Admin\ZksController@index'); //展示
        Route::get('user/{id}', 'Admin\ZksController@manager'); //管理员
        Route::get('client/{id}', 'Admin\ZksController@client'); //客户
        Route::get('contract/{id}', 'Admin\ZksController@contract'); //批次
        Route::get('expire/{clientName}', 'Admin\ZksController@expire'); //到期
        Route::get('station/{id}', 'Admin\ZksController@station'); //设备
        Route::get('hb6303/{id}', 'Admin\ZksController@hb6303'); //温湿度大气压设备详情
        Route::get('tester/{id}', 'Admin\ZksController@tester'); //今日主检工作量
        Route::get('vcr/{lanip}', 'Admin\ZksController@vcr'); //录像机
        Route::post('setOrder', 'Admin\ZksController@setOrder'); //设置排序
        Route::get('getEnvInfo', 'Admin\ZksController@getEnvInfo'); //获取环境信息
        Route::get('getContent', 'Admin\ZksController@getContent'); //获取中控室页面内容
    });
    
    Route::group(['prefix' =>'appWeb'], function() {
        Route::any('/', 'App\PublicController@index'); //首页
        Route::any('index', 'App\PublicController@index'); //首页
        Route::any('login', 'App\PublicController@login'); //登录
        Route::any('photo', 'App\PublicController@photo')->name('appPhoto'); //不合格照片、斗臂车
        Route::group(['prefix' => 'scan'], function() {
            Route::any('list', 'App\PublicController@scanList')->name('appScanList'); //扫描页列表
            Route::any('contract', 'App\PublicController@contract'); //受理批次
            Route::post('gaiyao', 'App\PublicController@gaiyao'); //提交受理
        });
    });
});

//PDA app 请求接口
Route::group(['prefix' =>config('constant.name_admin').'/app'], function() {
    Route::post('login', 'App\PublicController@login'); //登录
    Route::group(['prefix' => 'scan'], function() {
        Route::any('list', 'App\PublicController@scanList')->name('appScanList'); //扫描页列表
        Route::any('contract', 'App\PublicController@contract'); //受理批次
        Route::any('gaiyao', 'App\PublicController@gaiyao'); //提交受理
    });
});


Route::any(config('constant.name_admin').'/setInput', 'Admin\ItemDataController@setInput'); ////如果horizon不能用，则创建a_task表做定时任务进行input_data数据表的更新
Route::any(config('constant.name_admin').'/third/map/{third_id}', 'Admin\ThirdController@map')->where(['third_id'=>'2']); //////山东带电作业系统 -- 系统参数对照(暂时)

